<?php
#### CHECK INPUT ###############################################################
function checkGet($key = false) { 
	if (isset($_GET[$key])) return true; return false;
}
function checkPost($key = false) { 
	if (isset($_POST[$key])) return true; return false;
}
function checkRequest($key = false) { 
	if (isset($_REQUEST[$key])) return true; return false;
}
function checkPut($key = false) {
	global $put_array;
	parse_str(file_get_contents("php://input"), $_PUT);
	foreach ($_PUT as $tmp_key => $tmp_value) {
		if (array_key_exists($tmp_key, $put_array)) unset($_PUT[$tmp_key]);
	}
	foreach ($put_array as $tmp_key => $tmp_value) {
		if ($tmp_value) $_PUT[$tmp_key] = $tmp_value;
	}
	if (isset($_PUT[$key])) return true; return false;
}

#### GET INPUT #################################################################
function getGet($key = false) { 
	if (isset($_GET[$key])) return $_GET[$key]; 
	if (!$key) return $_GET;
}
function getPost($key = false) { 
	if (isset($_POST[$key])) return $_POST[$key]; 
	if (!$key) return $_POST;
}
function getRequest($key = false) { 
	if (isset($_REQUEST[$key])) return $_REQUEST[$key]; 
	return array_merge($_REQUEST, getPut());
}
function getPut($key = false) {
	global $put_array;
	if (!$put_array) $put_array = array();
	parse_str(file_get_contents("php://input"), $_PUT);
	foreach ($_PUT as $tmp_key => $tmp_value) {
		if (array_key_exists($tmp_key, $put_array)) unset($_PUT[$tmp_key]);
	}
	foreach ($put_array as $tmp_key => $tmp_value) {
		if ($tmp_value) $_PUT[$tmp_key] = $tmp_value;
	}
	if ($key) return $_PUT[$key];
	return $_PUT;
}

#### SET INPUT #################################################################
function setGet($key, $value = null) { 
	if (isset($value)) $_GET[$key] = $value;
	else unset($_GET[$key]);
}
function setPost($key, $value = null) { 
	if (isset($value)) $_POST[$key] = $value;
	else unset($_POST[$key]);
}
function setRequest($key, $value = null) { 
	if (isset($value)) $_REQUEST[$key] = $value;
	else unset($_REQUEST[$key]);
}
function setPut($key, $value = null) {
	global $put_array;
	if (isset($value)) $put_array[$key] = $value;
	else $put_array[$key] = null;
}
?>